Skip to content

fix(flow/retriever/parent): validate ParentIDKey is non-empty in NewRetriever#999

Open
octo-patch wants to merge 1 commit into
cloudwego:mainfrom
octo-patch:fix/issue-952-validate-parentidkey-in-retriever
Open

fix(flow/retriever/parent): validate ParentIDKey is non-empty in NewRetriever#999
octo-patch wants to merge 1 commit into
cloudwego:mainfrom
octo-patch:fix/issue-952-validate-parentidkey-in-retriever

Conversation

@octo-patch

Copy link
Copy Markdown

Fixes #952

Problem

NewRetriever in flow/retriever/parent validates Retriever and OrigDocGetter but silently accepts an empty ParentIDKey. When ParentIDKey is empty, Retrieve looks up subDoc.MetaData[""] for every sub-document — a key that is never populated — so the function silently returns empty results regardless of the actual retrieval output.

This is the retriever-side companion to the indexer fix in #953.

Solution

Added a config.ParentIDKey == "" validation check in NewRetriever, consistent with the existing field validation pattern.

Testing

Added TestNewRetrieverValidation covering all three required-field error cases (nil Retriever, nil OrigDocGetter, empty ParentIDKey). Existing TestParentRetriever passes unchanged.

…etriever

When ParentIDKey is empty, Retrieve silently finds no parent IDs for any
sub-document and always returns empty results. Return an explicit error from
NewRetriever when ParentIDKey is not provided, consistent with the validation
pattern used for the other required fields.

Fixes cloudwego#952

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bug: missing validation for empty ParentIDKey in flow/indexer/parent and flow/retriever/parent

1 participant